package com.sqfw.project.learnRecord.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqfw.common.utils.SecurityUtils;
import com.sqfw.project.learnRecord.domain.LearnRecordListen;
import com.sqfw.project.learnRecord.service.ILearnRecordListenService;
import com.sqfw.project.learnRecord.mapper.LearnRecordListenMapper;
import com.sqfw.project.learnRecord.vo.LearnRecordListenVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Optional;

/**
* @author BlueSony
*/
@Service
public class LearnRecordListenServiceImpl extends ServiceImpl<LearnRecordListenMapper, LearnRecordListen> implements ILearnRecordListenService {
    @Autowired
    private LearnRecordListenMapper recordListenMapper;

    @Override
    public int insertLearnRecordListen(LearnRecordListen learnRecordListen) {
        learnRecordListen.setCreateBy(Optional.ofNullable(SecurityUtils.getLoginUser()).map(loginUser -> loginUser.getUsername()).orElse(""));
        return baseMapper.insert(learnRecordListen);
    }

    @Override
    public List<LearnRecordListenVo> getGroupByUser() {
        return recordListenMapper.getGroupByUser();
    }

    @Override
    public List<LearnRecordListenVo> getByUserId(Long userId) {
        return recordListenMapper.getByUserId(userId);
    }
}




